﻿using System;
using COM.DTO;
using NHibernate;
using COM.Logging;
using NHibernate.Criterion;

namespace DAL.DAO
{
    public class HotelDAO
    {
        public static void Add(Hotel Hotel)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(Hotel);
                    transaction.Commit();
                }
            }
        }
        public static void Update(Hotel Hotel)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Update(Hotel);
                    transaction.Commit();
                }
            }
        }

        public static void Remove(Hotel Hotel)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Delete(Hotel);
                    transaction.Commit();
                }
            }
        }

        public static Hotel GetHotelById(String HotelId)
        {
            using (ISession session = NHibernateHelper.OpenSession())
                return session.Get<Hotel>(HotelId);
        }

    }
}
